<template>
  <div class="header">
    <div class="top">
      <h2>ToDoList</h2>
      <input
        @input="inputChange"
        :value="modelValue"
        type="text"
        @keydown.enter="add"
      />
    </div>

    <button @click="push1">我是兄弟1</button>
  </div>
</template>

<script>
import mitt from "../mitt";
export default {
  props: {
    modelValue: String,
  },
  setup(p, { emit }) {
    function inputChange(e) {
      console.log(e.target.value);
      emit("update:modelValue", e.target.value);
    }
    function add() {
      emit("add");
    }


    function push1() {
      mitt.emit("goAdd", 1);
    }

    return {
      inputChange,
      add,
      push1,
    };
  },
};
</script>

<style lang="scss" scoped>
.header {
  width: 100%;
  height: 50px;
  background-color: rgb(75, 75, 75);
  display: flex;
  align-items: center;
  .top {
    width: 50%;
    margin: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    input {
      width: 70%;
      height: 30px;
    }
  }
}
</style>
